﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGsBackground : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGsBackground(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGsBackground_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGsBackground obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGsBackground()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGsBackground(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdGsBackground cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsBackground_cast(OdRxObject.getCPtr(pObj));
			OdGsBackground result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsBackground)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsBackground)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsBackground)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsBackground_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsBackground_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsBackground_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGsBackground createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsBackground_createObject__SWIG_0();
			OdGsBackground result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsBackground)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsBackground)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsBackground)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGsBackground.BackgroundType type()
		{
			OdGsBackground.BackgroundType result = (OdGsBackground.BackgroundType)GlobalsPINVOKE.OdGsBackground_type(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void display(OdGsBaseVectorizer view, OdGiDrawable pDrawable, OdGiBackgroundTraitsData pBackgroundTraits, OdGsPropertiesDirectRenderOutput pdro)
		{
			GlobalsPINVOKE.OdGsBackground_display__SWIG_0(this.swigCPtr, OdGsBaseVectorizer.getCPtr(view), OdGiDrawable.getCPtr(pDrawable), OdGiBackgroundTraitsData.getCPtr(pBackgroundTraits), OdGsPropertiesDirectRenderOutput.getCPtr(pdro));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void display(OdGsBaseVectorizer view, OdGiDrawable pDrawable, OdGiBackgroundTraitsData pBackgroundTraits)
		{
			GlobalsPINVOKE.OdGsBackground_display__SWIG_1(this.swigCPtr, OdGsBaseVectorizer.getCPtr(view), OdGiDrawable.getCPtr(pDrawable), OdGiBackgroundTraitsData.getCPtr(pBackgroundTraits));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void nestedBackgroundDisplay(OdGsBaseVectorizer view, OdGiDrawable pDrawable, OdGiBackgroundTraitsData pBackgroundTraits, OdGsPropertiesDirectRenderOutput pdro)
		{
			GlobalsPINVOKE.OdGsBackground_nestedBackgroundDisplay__SWIG_0(this.swigCPtr, OdGsBaseVectorizer.getCPtr(view), OdGiDrawable.getCPtr(pDrawable), OdGiBackgroundTraitsData.getCPtr(pBackgroundTraits), OdGsPropertiesDirectRenderOutput.getCPtr(pdro));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void nestedBackgroundDisplay(OdGsBaseVectorizer view, OdGiDrawable pDrawable, OdGiBackgroundTraitsData pBackgroundTraits)
		{
			GlobalsPINVOKE.OdGsBackground_nestedBackgroundDisplay__SWIG_1(this.swigCPtr, OdGsBaseVectorizer.getCPtr(view), OdGiDrawable.getCPtr(pDrawable), OdGiBackgroundTraitsData.getCPtr(pBackgroundTraits));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void setNestedBackground(OdGsNestedBackground arg0)
		{
			GlobalsPINVOKE.OdGsBackground_setNestedBackground(this.swigCPtr, OdGsNestedBackground.getCPtr(arg0));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual OdGsNestedBackground getNestedBackground()
		{
			IntPtr intPtr = GlobalsPINVOKE.OdGsBackground_getNestedBackground(this.swigCPtr);
			OdGsNestedBackground result = (intPtr == IntPtr.Zero) ? null : new OdGsNestedBackground(intPtr, false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGsBackground createObject(OdGsBackground.BackgroundType type)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsBackground_createObject__SWIG_1((int)type);
			OdGsBackground result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsBackground)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsBackground)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsBackground)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		public enum BackgroundType
		{
			kSolidBackground,
			kGradientBackground,
			kImageBackground,
			kGroundPlaneBackground,
			kSkyBackground,
			kIBLBackground
		}
	}
}
